﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE;
using DAL;
using BE.SearchCriteria;

namespace BLL
{
    public class DivisionBLL : BaseBLL
    {
        public static List<DivisionBE> SeleccionarTodos()
        {
            DivisionDAL oDivisionDAL = new DivisionDAL();
            return oDivisionDAL.SeleccionarTodos();
        }

        public static List<ZonasBE> SeleccionarZonasPorDivision(int pIdDivision)
        {
            ZonaSC wFiltroSC = new ZonaSC();
            wFiltroSC.IdDivision = pIdDivision;
            int wCount = 0;
            List<ZonasBE> oZonas = ZonaBLL.SeleccionarTodos(wFiltroSC, 0, null, ref wCount);

            return oZonas;
        }

        public static List<AreaBE> SeleccionarAreasPorZona(int pIdZona)
        {
            AreaSC wFiltroSC = new AreaSC();
            wFiltroSC.IdZona= pIdZona;
            int wCount = 0;
            List<AreaBE> oAreas = AreaBLL.SeleccionarTodos(wFiltroSC, 0, null, ref wCount);

            return oAreas;
        }

        public static void Insertar(DivisionBE pElemBE)
        {
            try
            {
                Validar(pElemBE);

                DivisionDAL oDivisionDAL = new DivisionDAL();
                oDivisionDAL.Insertar(pElemBE);                
            }
            catch (Exception ex)
            {
                if (!HandleException(ex))
                    throw;
            }
        }

        public static void Modificar(DivisionBE pElemBE)
        {
            try
            {
                Validar(pElemBE);

                DivisionDAL oDivisionDAL = new DivisionDAL();
                oDivisionDAL.Modificar(pElemBE);
            }
            catch (Exception ex)
            {
                if (!HandleException(ex))
                    throw;
            }
        }

        public static void Delete(int pIdDivision)
        {
            try
            {
                DivisionDAL oDivisionDAL = new DivisionDAL();
                oDivisionDAL.Delete(pIdDivision);
            }
            catch (Exception ex)
            {
                if (!HandleException(ex))
                    throw;
            }
        }
        private static void Validar(DivisionBE pElemBE)
        {
            
        }

    }
}
